#include<bits/stdc++.h>
using namespace std;

int a[10005];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++) {
			if (a[i] != i)
				ans++, swap(a[i], a[a[i]]);
		}
	cout << ans;
	return 0;
}
